﻿using Commonality.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Commonality.Model.PLCControl;
using Merge.Model;
using System.Windows.Forms;

namespace Merge.BLL
{
    public partial class NodeForm : Form
    {
        public static NodeForm nodeForm;
        public NodeForm()
        {
            InitializeComponent();
            nodeForm = this;
        }

        private void NodeEntB_Paint(object sender, PaintEventArgs e)
        {

        }
        /// <summary>
        /// 入口扫码界面
        /// </summary>
        /// <param name="color"></param>
        public void NodeEntABackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                NodeEntA.BackColor = color;
            }));
        }
        public void NodeEntBBackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                NodeEntB.BackColor = color;
            }));
        }
        public void CaverA1PanelBackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverA1Panel.BackColor = color;
            }));
        }
        public void CaverB1PanelBackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverB1Panel.BackColor = color;
            }));
        }
        public void CaverA2PanelBackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverA2Panel.BackColor = color;
            }));
        }
        public void CaverB2PanelBackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverB2Panel.BackColor = color;
            }));
        }
        public void CaverA3PanelBackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverA3Panel.BackColor = color;
            }));
        }
        public void CaverB3PanelBackColor(Color color)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverB3Panel.BackColor = color;
            }));
        }
        /// <summary>
        /// 入口扫码界面
        /// </summary>
        /// <param name="text"></param>
        public void NodeEntAStaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                NodeEntASta.Text = text;
            }));
        }
        public void CaverA1StaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverA1Sta.Text = text;
            }));
        }
        public void CaverA2StaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverA2Sta.Text = text;
            }));
        }
        public void CaverA3StaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverA3Sta.Text = text;
            }));
        }

        public void NodeEntBStaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                NodeEntBSta.Text = text;
            }));
        }
        public void CaverB1StaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverB1Sta.Text = text;
            }));
        }
        public void CaverB2StaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverB2Sta.Text = text;
            }));
        }
        public void CaverB3StaText(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                CaverB3Sta.Text = text;
            }));
        }
        public void NodeInfoAStaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                NodeInfoA.Text = text;
            }));
        }
        public void AxisA1StaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                AxisA1.Text = text;
            }));

        }
        public void AxisA2StaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                AxisA2.Text = text;
            }));
        }
        public void AxisA3StaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                AxisA3.Text = text;
            }));
        }
        public void NodeInfoBStaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                NodeInfoB.Text = text;
            }));
        }
        public void AxisB1StaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                AxisB1.Text = text;
            }));
        }
        public void AxisB3StaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                AxisB3.Text = text;
            }));
        }
        public void AxisB2StaLab(string text)
        {
            this.BeginInvoke(new EventHandler(delegate
            {
                AxisB2.Text = text;
            }));
        }
        private void NodeEntA_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void CaverPanel_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                switch ((sender as Panel).Name)
                {
                    case "CaverA1Panel":
                        Log4Net.MsgInfo("强制清空A1轴目标");
                        CPLCControl.LAD_SetDblCell(PLC.dDestination_A1, 0);
                        break;

                    case "CaverA2Panel":
                        Log4Net.MsgInfo("强制清空A2轴目标");
                        CPLCControl.LAD_SetDblCell(PLC.dDestination_A2, 0);
                        break;

                    case "CaverA3Panel":
                        Log4Net.MsgInfo("强制清空A3轴目标");
                        CPLCControl.LAD_SetDblCell(PLC.dDestination_A3, 0);
                        break;

                    case "CaverB1Panel":
                        Log4Net.MsgInfo("强制清空B1轴目标");
                        CPLCControl.LAD_SetDblCell(PLC.dDestination_B1, 0);
                        break;

                    case "CaverB2Panel":
                        Log4Net.MsgInfo("强制清空B2轴目标");
                        CPLCControl.LAD_SetDblCell(PLC.dDestination_B2, 0);
                        break;

                    case "CaverB3Panel":
                        Log4Net.MsgInfo("强制清空B3轴目标");
                        CPLCControl.LAD_SetDblCell(PLC.dDestination_B3, 0);
                        break;
                }
            }
        }
    }
}
